const state = {
  token:sessionStorage.getItem(`token`)||``,
  userInfo:JSON.parse(sessionStorage.getItem(`userInfo`))||{},
  roleInfoList:JSON.parse(sessionStorage.getItem(`roleInfoList`))||[],
};

const getters = {
};

const mutations = {
//保存token
  setToken(state,token){
    sessionStorage.setItem(`token`,token)
    state.token=token;
  },
//保存用户登录信息
  setUserInfo(state, userInfo) {
    sessionStorage.setItem(`userInfo`, JSON.stringify(userInfo))
    state.userInfo = userInfo;
  },
  //保存菜单
  setRoleInfoList(state,roleInfoList){
    sessionStorage.setItem(`roleInfoList`, JSON.stringify(roleInfoList))
    state.roleInfoList=roleInfoList
  },
  }

const actions = {
  updateToken(context,value){
    context.commit('setToken',value)
  },
  updateUserInfo(context,value){
    context.commit('setUserInfo',value)
  },
  updateRoleInfoList(context,value){
    context.commit('setRoleInfoList',value)
  },
  }
  
 export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}